package com.home.customtest.typehandle;

/**
 * @author XiaoBai
 * @since 2024/4/9 13:45
 */
public enum StatusEnum {

    NORMAL(1, "正常"),
    DELETE(2, "删除"),
    LOGOFF(3, "注销"),
    ;

    private final Integer code;
    private final String desc;

    StatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static StatusEnum getByCode(Integer code) {
        for (StatusEnum value : StatusEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static StatusEnum getByDesc(String desc) {
        for (StatusEnum value : StatusEnum.values()) {
            if (value.getDesc().equals(desc)) {
                return value;
            }
        }
        return null;
    }
}
